package com.shop.admin.service.user;

import com.shop.admin.dao.user.SleepPinkBillDao;
import com.shop.domain.user.SleepPinkBill;
import com.shop.web.response.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

@Service
@Slf4j
@Transactional
public class SleepPinkBillService {

    @Autowired
    private SleepPinkBillDao sleepPinkBillDao;

    /**
     * 增加休眠用户团队记录流水
     * @param userId  用户ID
     * @param linkId  关联ID（拼团订单ID）
     * @param pinkId  拼团ID
     * @param price  佣金
     * @param tableName 业务类型
     * @param pm 流水类型 0收入 1支出
     * @param mark 备注
     * @return
     */
    public BaseResponse addUserPinkBill(Long userId, Long linkId,Long pinkId, BigDecimal price, String tableName,
                                     int pm, String mark) {

        SleepPinkBill sleepPinkBill = new SleepPinkBill();
        sleepPinkBill.setUid(userId);
        sleepPinkBill.setLinkId(linkId);
        sleepPinkBill.setPinkId(pinkId);
        sleepPinkBill.setPrice(price);
        sleepPinkBill.setTableName(tableName);
        sleepPinkBill.setPm(pm);
        sleepPinkBill.setMark(mark);
        sleepPinkBillDao.save(sleepPinkBill);

        return new BaseResponse();
    }


}
